package cn.hunqing.web.dto;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

import cn.hunqing.web.entity.WeddingInvitationComment;

public class WeddingInvitationCommentDto {
	private long id;

	private String userName;

	private String comment;

	private String createdDate;
	private String createdTime;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public String getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(String createdDate) {
		this.createdDate = createdDate;
	}

	public String getCreatedTime() {
		return createdTime;
	}

	public void setCreatedTime(String createdTime) {
		this.createdTime = createdTime;
	}

	public static WeddingInvitationCommentDto buildFrom(WeddingInvitationComment weddingInvitationComment) {
		if(weddingInvitationComment == null){
			return null;
		}
		WeddingInvitationCommentDto newWeddingInvitationCommentDto = new WeddingInvitationCommentDto();
		newWeddingInvitationCommentDto.setComment(weddingInvitationComment.getComment());
		if(weddingInvitationComment.getCreatedAt() != null){
			DateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd");  
			newWeddingInvitationCommentDto.setCreatedDate(formatDate.format(weddingInvitationComment.getCreatedAt())); 
			DateFormat formatTime = new SimpleDateFormat("HH:mm");  
			newWeddingInvitationCommentDto.setCreatedTime(formatTime.format(weddingInvitationComment.getCreatedAt())); 
		}
		newWeddingInvitationCommentDto.setUserName(weddingInvitationComment.getUserName());
		newWeddingInvitationCommentDto.setId(weddingInvitationComment.getId());
		return newWeddingInvitationCommentDto;
	}

}
